package com.example.saiweisi.controller.userController;

import com.example.saiweisi.common.Result;
import com.example.saiweisi.controller.request.DiancanRequest;
import com.example.saiweisi.controller.request.HistoryOrderRequest;
import com.example.saiweisi.controller.request.YueyueRequest;
import com.example.saiweisi.controller.request.YuyueRequest;
import com.example.saiweisi.service.impl.userService.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RequestMapping("/yuyue")
@RestController
@CrossOrigin
@Slf4j
public class YuyueController {
    @Autowired
   private OrderService orderService;

    @PostMapping("/submit/{userId}")
    public Result submitOrder(@PathVariable Integer userId, @RequestBody YuyueRequest request) {
        Map<String, String> yuyue = orderService.yuyue(userId, request);
        return Result.success(yuyue);
    }

    @GetMapping("/history")
    public Result getHistoryYuyue(HistoryOrderRequest historyOrderRequest) {
        return Result.success(orderService.getHistoryYuyue(historyOrderRequest));
    }

    @DeleteMapping("/delete{id}")
    public Result deleteyuyue(@PathVariable Integer id) {
        orderService.deleteyuyue(id);
        return Result.success();
    }

    @GetMapping("/getAll")
    public Result getAll(YueyueRequest yueyueRequest) {
        return Result.success(orderService.getAll(yueyueRequest));
    }
    @PutMapping("/wan{yueyueId}")
    public Result wan(@PathVariable Integer yueyueId) {
        orderService.wan(yueyueId);
        return Result.success();
    }
}
